package data;

import data.Dao;

public class User {

	private String email;
	private String name;
	private String password;
	private double balance;
	private boolean isAdmin;
	private Dao db;

	public User(String email, String name, String password, double balance, boolean isAdmin) {
		db = new Dao();

		this.email = email;
		this.name = name;
		this.password = password;
		this.balance = balance;
		this.isAdmin = isAdmin;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public double getBalance() {
		return balance;
	}

	public void setBalance(double balance) {
		this.balance = balance;
	}


	public boolean getIsAdmin() {
		return isAdmin;
	}

	public void setAdmin(boolean isAdmin) {
		this.isAdmin = isAdmin;
	}
	
	public User getUserWithUsername(String username){
		for(User user : db.getUsers())
		{
			if(user.getEmail().equals(username))
			{
				return user;
			}
		}
		return null;
	}
}